

var addMicro = function()
{
	$('input#mic').on('webkitspeechchange',function() 
	{
			$('#search_query').val($('#mic').val());
			$('#mic').val("");
			$('#search_query').focus();
	});
	
}


var insertEasterEggs = function()
{
    if ( window.addEventListener ) {     
          var state = 0, do_want = [38,38,40,40,37,39,37,39,66,65];     
          window.addEventListener("keydown", function(e) { 
                if ( e.keyCode == do_want[state] ) state++; 
                else state = 0; 
                if ( state == 10 ) 
                  $('#easterEgg').modal();
                }, true); 
          }
}


$(document).ready(function()
{
	addMicro();
	insertEasterEggs();
	
	// Ajout dynamique de nouveau champs d'upload (inscription)
    $("button#add_field").click(function (){
	var nb = $('div.upload').length;
	
	if(nb < 5)
		$('div.upload:eq('+(nb-1)+')').after('<div class="control-group upload"><label class="control-label" for="avatar'+(nb+1)+'">Autre image de profil</label><div class="controls"><input type="file" name="file_'+(nb+1)+'" id="avatar'+(nb+1)+'" /></div></div>');
	
	});
	
	
	
});
	

